package com.magesti.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.magesti.exception.OtherException;
import com.magesti.ressource.Global;
// pour eviter le warning de "Global
//Cette servlet sert de prototye pour creer de nouveaux servlet !

@SuppressWarnings("serial")
public class Erreur extends HttpServlet {

	public void init() throws ServletException {

	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		Exception exception = (Exception) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
		try{
			throw new OtherException(exception);
		}catch(OtherException e){
			e.printStackTrace();
		}
		
		this.getServletContext().getRequestDispatcher(Global.VUE_JSP_ERREUR).forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//Peut recommander en  general, utile ici.
		doGet(request,response);
	}

}
